home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-15 | 3.0 KB | 151 lines | [TEXT/CWIE] |
- /*
-
- File: UGuide.cp
- Project: Sprocket Framework 1.1 (DR2), released 6/15/96
- Contains: Apple Guide utilities
- To Do: ?
-
- Sprocket Major Contributors:
- ----------------------------
- Dave Falkenburg, producer of Sprocket 1.0
- Bill Hayden, producer of Sprocket 1.1
- Steve Sisak, producer of the upcoming Sprocket 2.0
-
- Pete Alexander Steve Falkenburg Randy Thelen
- Eric Berdahl Nitin Ganatra Chris K. Thomas
- Marshall Clow Dave Hershey Leonard Rosenthal
- Tim Craycroft Dave Mark Dean Yu
- David denBoer Gary Powell
- Cameron Esfahani Jon Summers Apple Computer, Inc.
-
- Comments, Additions, or Corrections:
- ------------------------------------
- Bill Hayden, Nikol Software <nikol@codewell.com>
-
- */
-
- // If you remove this file from your project, you may safely remove the following files:
- // AGFileLib68K
- // AGFileLibPPC
- // AppleGuideGlueLib.xcoff
-
-
- #ifndef __PROCESSES__
- #include <Processes.h>
- #endif
-
- #include "Sprocket.h"
- #include "UString.h"
- #include "UGuide.h"
- #include "AGFile.h"
-
-
- static UInt32 gGuideRefNum;
-
-
-
- static OSErr GetAppFileSpec(FSSpecPtr pFileSpec);
-
-
-
- /*****************************************************************************/
-
-
-
- OSErr OpenGuideFile(void)
- {
- #if qDebug
- if (!gHasAppleGuide)
- {
- DebugMessage("\pApple Guide called, but not installed");
- return paramErr;
- }
- #endif
-
- return AGOpen(nil, 0, nil, &gGuideRefNum);
- }
-
-
-
- /*****************************************************************************/
-
-
- // Guide file must be in the same folder as the application
-
-
- OSErr OpenGuideFileWithSearch(ConstStr255Param SearchString)
- {
- FSSpec fileSpec;
- short vRefNum;
- long dirID;
- OSErr result;
-
- #if qDebug
- if (!gHasAppleGuide)
- {
- DebugMessage("\pApple Guide called, but not installed");
- return paramErr;
- }
- #endif
-
- // Get the file spec for this application.
-
- result = GetAppFileSpec(&fileSpec);
-
- if (result == noErr)
- {
- vRefNum = fileSpec.vRefNum;
- dirID = fileSpec.parID;
-
- // Use AGFileLib to get the file spec
- // for the first guide file of guide type HELP.
-
- result = AGFileGetIndDB(vRefNum, dirID, kAGFileDBTypeHelp, false, 1, &fileSpec);
- if(result==noErr)
- {
- // Open guide file resource fork.
-
- gGuideRefNum = FSpOpenResFile(&fileSpec, fsRdPerm);
- if(gGuideRefNum != -1)
- {
- // Done with guide file.
-
- (void) FSClose(gGuideRefNum);
-
- // Open guide file with search phrase.
-
- if(SearchString[0] > 0)
- result = AGOpenWithSearch(&fileSpec, 0, nil,
- SearchString, &gGuideRefNum);
- }
- }
- }
-
- return result;
- }
-
-
-
-
- /*****************************************************************************/
-
-
-
-
- OSErr GetAppFileSpec(FSSpecPtr theFileSpec)
- {
- ProcessSerialNumber currentProcess;
- ProcessInfoRec infoRec;
- OSErr result;
-
- currentProcess.highLongOfPSN = 0;
- currentProcess.lowLongOfPSN = kCurrentProcess;
- infoRec.processInfoLength = sizeof(infoRec);
- infoRec.processName = nil;
- infoRec.processAppSpec = theFileSpec;
- result = GetCurrentProcess(¤tProcess);
- if(result == noErr)
- result = GetProcessInformation(¤tProcess, &infoRec);
- return result;
- }
-